<template>
	<view class="releasePlan-content">
		<view class="release-list">
			<newList :list="list" imgField="course_img" titleField="course_title" tipsField="lessson_title"
				timeField="time" @handleClick="detailsClick"></newList>
		</view>
	</view>
</template>

<script>
	import {
		getTrainingIndex
	} from "../../../static/js/api/training.js"
	import newList from "../../../components/new_list/index.vue"
	export default {
		components: {
			newList,
		},
		data() {
			return {
				list: [],
			}
		},
		onLoad(option) {
			if (option.class_id) {
				this.getData(option.class_id)
			}
			// this.getData()
		},
		methods: {
			getData(classId) {
				getTrainingIndex({
					page: 1,
					per_page: 9999,
					class_id: classId
				}).then(res => {
					console.log(res.trainings)
					if (res.trainings) {
						res.trainings.forEach(item => {
							let times = item.create_time.split(" ")
							item.time = times[0]
						})
						this.list = res.trainings
					}
				})
			},
			detailsClick(item) {
				console.log(item)
				uni.navigateTo({
					url: "/pages/releasePlan/correctPlan/planStudent?trainingId=" + item.training_id + '&time=' + item.time
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url("./index.scss");

	.text_opblack {
		color: $uni-text-color-opblack;
	}

	.text_black {
		color: $uni-text-color-black;
	}

	.text_active {
		color: #FF6E00 !important;
	}
	.releasePlan-content{
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}
	.release-list {
		/deep/ .list-item{
			margin-bottom: 20rpx;
			background: #ffffff;
		}
	}
</style>